package com.oldbook.manage.controller;

import com.oldbook.common.annotation.Log;
import com.oldbook.common.core.controller.BaseController;
import com.oldbook.common.core.domain.AjaxResult;
import com.oldbook.common.core.page.TableDataInfo;
import com.oldbook.common.enums.BusinessType;
import com.oldbook.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.oldbook.manage.domain.VClassTextbookReport;
import com.oldbook.manage.service.IVClassTextbookReportService;


/**
 * 视图Controller
 *
 * @author Exiaoke
 * @date 2025-02-18
 */
@RestController
@RequestMapping("/manage/report")
@Api(tags = "视图管理")
public class VClassTextbookReportController extends BaseController {

    @Autowired
    private IVClassTextbookReportService vClassTextbookReportService;

/**
 * 查询视图列表
 */
@PreAuthorize("@ss.hasPermi('manage:report:list')")
@GetMapping("/list")
@ApiOperation("查询视图列表")
    public TableDataInfo list(@ApiParam("视图对象") VClassTextbookReport vClassTextbookReport) {
        startPage();
        List<VClassTextbookReport> list = vClassTextbookReportService.selectVClassTextbookReportList(vClassTextbookReport);
        return getDataTable(list);
    }

    /**
     * 导出视图列表
     */
    @PreAuthorize("@ss.hasPermi('manage:report:export')")
    @Log(title = "视图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出视图列表")
    public void export(HttpServletResponse response, @ApiParam("视图对象") VClassTextbookReport vClassTextbookReport) {
        List<VClassTextbookReport> list = vClassTextbookReportService.selectVClassTextbookReportList(vClassTextbookReport);
        ExcelUtil<VClassTextbookReport> util = new ExcelUtil<VClassTextbookReport>(VClassTextbookReport.class);
        util.exportExcel(response, list, "视图数据");
    }

    /**
     * 获取视图详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:report:query')")
    @GetMapping(value = "/{专业}")
    @ApiOperation("获取视图详细信息")
    public AjaxResult getInfo(@PathVariable("专业") @ApiParam("专业的值") String 专业) {
        return success(vClassTextbookReportService.selectVClassTextbookReportBy专业(专业));
    }

    /**
     * 新增视图
     */
    @PreAuthorize("@ss.hasPermi('manage:report:add')")
    @Log(title = "视图", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增视图")
    public AjaxResult add(@RequestBody @ApiParam("要添加的视图对象") VClassTextbookReport vClassTextbookReport) {
        return toAjax(vClassTextbookReportService.insertVClassTextbookReport(vClassTextbookReport));
    }

    /**
     * 修改视图
     */
    @PreAuthorize("@ss.hasPermi('manage:report:edit')")
    @Log(title = "视图", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改视图")
    public AjaxResult edit(@RequestBody @ApiParam("要修改的视图对象") VClassTextbookReport vClassTextbookReport) {
        return toAjax(vClassTextbookReportService.updateVClassTextbookReport(vClassTextbookReport));
    }

    /**
     * 删除视图
     */
    @PreAuthorize("@ss.hasPermi('manage:report:remove')")
    @Log(title = "视图", businessType = BusinessType.DELETE)
    @DeleteMapping("/{专业s}")
    @ApiOperation("删除视图")
    public AjaxResult remove(@PathVariable @ApiParam("要删除的专业数组") String[] 专业s) {
        return toAjax(vClassTextbookReportService.deleteVClassTextbookReportBy专业s(专业s));
    }
}